package com.mall.dto;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
 * 订单创建DTO
 * 
 * @author Mall Team
 */
@Data
public class OrderCreateDTO {
    
    @NotEmpty(message = "购物车商品不能为空")
    private List<Long> cartIds;  // 购物车ID列表
    
    @NotBlank(message = "收货人姓名不能为空")
    private String receiverName;
    
    @NotBlank(message = "收货人电话不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String receiverPhone;
    
    @NotBlank(message = "收货地址不能为空")
    private String receiverAddress;
    
    private String remark;  // 订单备注
    
    /**
     * 直接购买DTO（不通过购物车）
     */
    @Data
    public static class DirectOrderDTO {
        @NotEmpty(message = "商品信息不能为空")
        private List<OrderItem> items;
        
        @NotBlank(message = "收货人姓名不能为空")
        private String receiverName;
        
        @NotBlank(message = "收货人电话不能为空")
        @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
        private String receiverPhone;
        
        @NotBlank(message = "收货地址不能为空")
        private String receiverAddress;
        
        private String remark;
        
        @Data
        public static class OrderItem {
            private Long productId;
            private Integer quantity;
        }
    }
}